package com.polaris.live.popup

import android.content.Context
import android.view.View
import com.blankj.utilcode.util.StringUtils
import com.lxj.xpopup.XPopup
import com.lxj.xpopup.core.AttachPopupView
import com.polaris.live.R
import com.polaris.live.databinding.PopupGiftrecordTipsBinding
import com.polaris.live.translation.R.string

/**
 *
 * 获赠记录 提示
 * @author Created by 天晴 on 2024/7/17 16:24
 * @since 1.0.0
 **/
class GiftRecordTipsPopup(
    context: Context,
    val type: Int,  //    1 代表正在有效期内  2 代表未开始使用  3代表已经过期
) : AttachPopupView(context) {

    private lateinit var mBinding: PopupGiftrecordTipsBinding
    override fun getImplLayoutId(): Int {
        return R.layout.popup_giftrecord_tips
    }

    override fun onCreate() {
        mBinding = PopupGiftrecordTipsBinding.bind(popupImplView)
        when (type) {
            1 -> {
                mBinding.tipsTv.text = StringUtils.getString(string.validity_period)
                mBinding.timeImg.setImageResource(R.drawable.giftrecord_3)
            }

            2 -> {
                mBinding.tipsTv.text = StringUtils.getString(string.not_started_using)
                mBinding.timeImg.setImageResource(R.drawable.giftrecord_2)
            }

            3 -> {
                mBinding.tipsTv.text = StringUtils.getString(string.representative_expired)
                mBinding.timeImg.setImageResource(R.drawable.giftrecord_1)
            }
        }
    }


    companion object {

        fun show(context: Context, view: View, type: Int) {
            XPopup.Builder(context)
                .moveUpToKeyboard(false)
                .isDestroyOnDismiss(true)
                .enableDrag(false)
                .atView(view)
                .hasShadowBg(false)
                .asCustom(GiftRecordTipsPopup(context, type))
                .show()
        }
    }
}